package demo.mvc.controllers
{
	import demo.mvc.views.login.LoginView;
	import demo.mvc.views.main.MainView;
	
	import com.gamefx.mvc.Command;
	import com.gamefx.mvc.Facade;
	import com.gamefx.mvc.classes.Notification;
	
	public class SceneCommand extends Command
	{
		private static var lastScene:String;
		
		override public function execute(notification:Notification):void
		{
			if (lastScene)
			{
				facade.removeView( lastScene );
			}
			
			lastScene = notification.getBody() as String;

			switch (lastScene)
			{
				case Facade.Name(LoginView):
					facade.registerView( new LoginView() );
					break;
				
				case Facade.Name(MainView):
					facade.registerView( new MainView() );
					break;
				
				default:
					lastScene = null;
					break;
			}
			
		}
	}
}